import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-user-login',
  templateUrl: './user-login.component.html',
  styleUrls: ['../user.component.scss']
})
export class UserLoginComponent implements OnInit {

  public loginForm = this.fb.group({
    'userName': ['', [Validators.required]],
    'password': ['', [Validators.required, Validators.minLength(8)]],
    'remeberMe': ['false']
  });

  constructor(
    private fb: FormBuilder,
    private route: ActivatedRoute,
    private router: Router
  ) { }

  ngOnInit() {

  }

  doLogin() {
    console.info(this.loginForm.value);
    this.router.navigateByUrl('/layout');
  }

  toRegister() {
    // relativeTo：相对于当前路径做跳转，传入ActivatedRoute对象
    this.router.navigate(['../register'], { relativeTo: this.route });
  }

  forgetPwd() {

  }

}
